package org.huangrui.spark.java.core.rdd.serial;

import org.apache.spark.SparkConf;
import org.apache.spark.api.java.JavaRDD;
import org.apache.spark.api.java.JavaSparkContext;

import java.util.Arrays;
import java.util.List;

/**
 * @Author hr
 * @Create 2024-10-18 13:29
 */
public class Spark01_RDD_Serial_2 {
    public static void main(String[] args) {
        final SparkConf conf = new SparkConf().setMaster("local[*]").setAppName("spark");
        final JavaSparkContext jsc = new JavaSparkContext(conf);

        final List<Integer> nums = Arrays.asList(1, 2, 3, 4);
        final JavaRDD<Integer> rdd = jsc.parallelize(nums, 2);

        rdd.foreach(num -> System.out.println(num));
        // TODO JDK1.8的函数式编程其实采用的是对象模拟出来的。

        // final PrintStream out = System.out;
        // rdd.foreach( out::println );


        jsc.close();
    }
}
